﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIPanalManager : MonoBehaviour 
{
	public GameObject panalObj;

	// Use this for initialization
	void Start () 
	{
		PlayerData.Instance.InitGame ();
		CreatPanal ();
//		UIScenenManager.getInstance ().openSceneUI ();
		//		UIManager.getInstance ().openDialog (new UIMain());
		UIManager.getInstance ().openDialog (new UIMenu());
	}

	void CreatPanal()
	{
		float posY = 0;
		var gap = 100;

		foreach(string panalName in System.Enum.GetNames(typeof(UIManager.panelLayerName)))
		{
			GameObject panalObject = (GameObject)Instantiate (panalObj);
			UIPanal panal = panalObject.AddComponent<UIPanal> ();
			panal.name = panalName;
			panal.transform.parent = transform;

			var rect = panal.GetComponent<RectTransform> ();
			rect.localScale = new Vector3 (1, 1, 1);
			rect.offsetMin = new Vector2 (0,0);
			rect.offsetMax = new Vector2 (0,0);

			UIManager.getInstance().panalLayer[panalName] = panal;
//			panal.transform.localPosition = new Vector3(panal.transform.localPosition.x, panal.transform.localPosition.y, posY);
			posY = gap;
		}
	}
	
	// Update is called once per frame
	void Update () 
	{
		
	}
}                                   